//
//  UIBarButton+Button.swift
//  MYSwiftWeiBo
//
//  Created by shingwai chan on 16/3/1.
//  Copyright © 2016年 ChanShingWai. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

    convenience init(imageName: String) {
        let button = UIButton()
        button.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        button.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        button.sizeToFit()
        self.init(customView: button)
    }
    
    
    class func barBottonItem(imageName: String) -> UIBarButtonItem {
        
        let button = UIButton()
        button.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        button.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        button.sizeToFit()
        return UIBarButtonItem(customView: button)
    }
}

